/****************************************************************************
** This is the main file for the replication dataset of "Econographics" 	*
** by Chapman et al., Published in "JPE:Micro"								*
**																			*
** This file runs the do files needed to produce all output, in the proper 	*
** 		order. Contains configurable global variables as well.				*
**																			*
** Produced by Erik Snowberg, October 13, 2022								*
** 		Based on Code by Jonathan Chapman and Erik Snowberg					*
****************************************************************************/

drop _all
clear matrix
clear mata
clear
set more off

// Number of bootstrap replications for SEs (0=asymptotic SEs)
// Note 10000 repetitions takes around 10 minutes for 1 correlation
// so run only after testing with 0 and maybe 100.
global bootstrapReps = 10000

//either navigate to current directory in Stata, 
//or uncomment and put directory of replication bundle here 
//cd ""

//relative paths--where other do files can be found
global dofilepath = "dofiles/"
//where to put table and figure outputs
global outputpath = "output/"
//where to put (and look for) datasets other than the main econographics.dta
//(which is assumed to be in the directory you are executing this code from)
global datapath = "datasets/"

//takes in main datafile, and transforms some data for analysis.
do "${dofilepath}econographicsTransform.do"
//descriptive statistics table in Section 4.1
do "${dofilepath}econographicsDescriptiveStats.do"
//Correlation Matricies and PCA for Sections 4.2-4.4
do "${dofilepath}corrsAndPCA.do"
//Relationship between components and IQ/Demographics in Section 5
do "${dofilepath}factorsIQDemograhics.do"
//Some additional, mostly sensible, robustness checks for the Appendix. 
//Do not need bootstrapped standard errors here, so change to no BS
global bootstrapReps = 0
do "${dofilepath}corrsAndPCAVariants.do"
